package ua.cs.stu.ics.dao.dbf;

import ua.cs.stu.ics.dao.IMarkNewDAO;
import ua.cs.stu.ics.dbf.domain.MarkNewDomain;
import ua.cs.stu.ics.dbf.domain.StudentDomain;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: 26.02.11
 * Time: 16:21
 * To change this template use File | Settings | File Templates.
 */
public class MarkNewDAO implements IMarkNewDAO{
    private ArrayList<MarkNewDomain> list = new ArrayList<MarkNewDomain>();

    public void add(MarkNewDomain domain) {
        list.add(domain);
    }

    public List findAll() {
        return list;
    }

    public List getSection(String type, StudentDomain studentDomain){
        ArrayList<MarkNewDomain> res = new ArrayList<MarkNewDomain>();
        for (MarkNewDomain mark: list){
            if (mark.getType().equals(type) && studentDomain.getNZach().equals(mark.getNZach()))
                res.add(mark);
        }
        return res;
    }

    public int getSumTime(StudentDomain studentDomain){
        int res =0;
        for (MarkNewDomain mark: list){
            if (studentDomain.getNZach().contains(mark.getNZach()))
                res+= mark.getHours();
        }
        return res;
    }
}
